earthenringfandomcom-20200214-history
PERL chatlogging filter script
This article presents and documents a PERL script to filter a chatlog for Story Night purposes. This article assumes that the reader has at least a passing familiarity with Perl, knows how to execute a PERL script, has the means to do so, and has the technical skills necessary to adapt the contents of this article to his or her operating environment. This article assumes that the person recording the Story Night log is not using any User Interface modifications that would affect the output of the Blizzard default UI command "/chatlog". Procedure: First, anyone who intends to record a log of Story Night should invoke the command "/chatlog". The chat window should respond with "Chat being logged to Logs\WoWChatLog.txt". It is preferable that this command be invoked before you enter the zone. Second, once Story Night is over, invoke "/chatlog" again. The chat window should respond with "Chat logging disabled." Contingency to the above: If you disconnect during Story Night, you will need to go to your "World of Warcraft" folder, go into the "Logs" subfolder, and either move or rename the file WoWChatLog.txt. If you do not do this, there is a risk that when you reconnect and invoke "/chatlog" again, your previous logs will be overwritten and lost permanently. Reconnect to the game, then invoke "/chatlog" to resume logging. Third, run the script, below. From what I understand, the procedure for running PERL scripts in general depends upon the operating environment. There is no one set of instructions that will work for everyone. Therefore, it is the reader's responsibility to understand how to correctly run this script. Fourth, take the filtered chat log and post it here to the Earthen Ring Wiki as a new article. Attach Category:Story Night to the bottom of the article. ---- The script that I use is presented below: #!usr/bin/perl open(my $in, "<", "WoWChatLog.txt") or die "Can't open WoWChatLog.txt: $!"; open(my $out, ">", "FilteredLog.txt") or die "Can't open FilteredLog.txt: $!"; my @blacklist = ( '\w{1,12} whispers:', 'To \w{1,12}:', ' \Party\ \w{1,12}:', '\\w+\', # This removes all channel chatter. '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12} has come online\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12} has gone offline\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12} added to friends\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12} removed from friends list\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12} joins the party\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12} leaves the party\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12}: Level \d{1,2} \w+ (Elf |)\w+( <\w{1,24}>)?', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \d{1,2} player(s?) total', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} You are now AFK: Away from Keyboard', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} You are no longer AFK\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} \w{1,12} has invited you to join a group\.', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} Looting changed to ', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} Loot threshold set to ', '\d{1,2}\/\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3} You leave the group\.' ); while (<$in>) { # assigns each line in turn to $_ my $signal = 0; foreach $patt (@blacklist) { if ( /${patt}/i ) { $signal++; } } if ($signal 0) { print $out $_; } } close $in or die "$in: $!"; close $out or die "$out: $!"; Notes about the script: A typical line from the chatlog will look like this: 2/24 21:38:13.925 Cogitatus silently nods in greeting at Remia, then returns his attention to Calithos. The script will scan through the raw chatlog and remove the following things: All incoming and outgoing whispers All /party chat All channel chatter (General, Trade, funhouse, the RSP data channel, everything) Friendlist/guild online/offline notices. Changes to your Friendlist Joining, being invited to, or leaving an ordinary group The results of any "/who" queries AFK notifications Loot setting changes As written, I need to have the script and the unfiltered chat log in the same folder for the script to work. On Mac System 10.3.9, I run the Terminal, use the "cd" command to get to the necessary folder, and invoke "perl RSPlogfilter3.txt" to run the script. (The text file that contains my script is called "RSPlogfilter3.txt" because I wrote the original version to only identify and remove the RSP data channel chatter from my chatlog. You can use a different name for the script.) Category:Story Night